package controller.content;

import controller.entity.Combobox;
import entity.Storehouse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import service.StoreService;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by asus on 2017/6/22.
 */
@Controller
@RequestMapping("/store")
public class StoreController {
    @Autowired
    private StoreService storeService;

    @RequestMapping("/simplelist")
    @ResponseBody
    public List<Combobox> getSimpleList(){
        List<Storehouse> storehouses=storeService.getAll();
        List<Combobox> comboboxes=new ArrayList<>();
        Combobox combobox;
        for(Storehouse s:storehouses){
            combobox=new Combobox();
            combobox.setId(s.getId());
            combobox.setText(s.getName());
            comboboxes.add(combobox);
        }
        return comboboxes;
    }
}
